﻿using Infrastructure;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Web.Resource;

namespace Web.Controllers
{
    /// <summary>
    /// keditor图片上传处理程序   
    /// </summary>
    public class KEditorController : Controller
    {
        /// <summary>
        /// keditor图片上传处理程序
        /// </summary>        
        /// <returns></returns>
        public ActionResult Index()
        {
            var imageFile = Request.Files[0];       
            var url = ResManage.SavePostedFile(imageFile, ResType.KEditor, Guid.NewGuid()).UrlName;
            Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            return Content(JsonSerializer.ToJson(new { error = 0, url = url, state = "SUCCESS", original = imageFile.FileName }));
        }
    }
}
